package com.leyu.mall.admin.cms.service.impl;

import java.util.List;
import java.util.Random;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.leyu.mall.admin.cms.dao.AccountMapper;
import com.leyu.mall.admin.cms.domain.Account;
import com.leyu.mall.admin.cms.service.IAccountService;
 
@Service
@Transactional(rollbackFor=Exception.class)
public class AccountServiceImpl  implements IAccountService {

	
	@Resource(name="accountMapper")
	private AccountMapper accountMapper;
	
	
	public boolean addAccount(Account entity) throws Exception{
		entity.setAccountId(new Random().nextInt(99999));
		accountMapper.addAccount(entity);
		
		 return true;
	}

	public Account getAccount(Long id) throws Exception {
		return accountMapper.getAccountById(id);
	}
 
	@Transactional(readOnly=true,propagation=Propagation.NOT_SUPPORTED)
	public List<Account> getAccounts() throws Exception {
		
		return accountMapper.getAllAccount();
	}
	
	public List<Account> getList(){
		return accountMapper.getAllAccount();
	}

}
